/*
 * Copyright (C) 2014 Nathan T
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package engine.game.level.pathfinding;

import java.awt.Point;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Nathan T
 */
public class Path {
    
    private final List<Point> points;
    private int currentIndex = 0;
    
    public Path(ArrayList<Point> points) {
        this.points = points;
    }
    
    public List<Point> getPoints() {
        return points;
    }
    
    public Point nextPoint() {
        if (currentIndex < points.size()) {
            Point returnPoint = points.get(currentIndex);
            currentIndex++;
            return returnPoint;
        }
        return null;
    }
    
    public void resetTrace() {
        currentIndex = 0;
    }
    
    public int getLength() {
        return points.size();
    }
    
    public int getWalkLength() {
        return points.size() -1;
    }
    
    @Override
    public String toString() {
        String output = "";
        
        int index = 0;
        for(Point point : points) {
            output += point.x + ", " + point.y;
            if (index < (points.size() - 1)) {
                output += "\n";
            }
            index++;
        }
        
        return output;
    }
    
}
